using System;

namespace Phoenix.Framework
{
    public abstract class ControllerFactoryBase : IControllerFactory
    {
        public T Create<T>(ControllerActionContext context) where T : Controller
        {
            var controller = CreateController<T>();
            controller.Initialise(context);
            return controller;
        }

        public Controller Create(Type controllerType, ControllerActionContext context)
        {
            var controller = CreateController(controllerType);
            controller.Initialise(context);
            return controller;
        }

        protected abstract T CreateController<T>() where T : Controller;
        protected abstract Controller CreateController(Type controllerType);

        public abstract void Release(Controller controller);
    }
}